package model;

/**
 * The POJO for a Nutrition item
 * @author Lawrence Grass, Kevin Hedglin
 */
public class NutritionItem 
{
	/**
	 * The name of the item
	 */
	private String item;
	
	/**
	 * The cost per each item
	 */
	private int calories;
	
	/**
	 * Is it on sale?
	 */
	private int total_fat;
	
	private int cholesterol;
	
	private int carbohydrates;
	
	private int sodium;
	
	private int protein;
	
	/**
	 * Constructs a POJO representation of an item
	 * @param item name
	 * @param price of the item
	 * @param sale if it's on sale
	 */
	public NutritionItem(String item, int calories, int total_fat, int cholesterol,
						 int sodium, int carbohydrates, int protein)
	{
		this.item = item;
		this.calories = calories;
		this.cholesterol = cholesterol;
		this.carbohydrates = carbohydrates;
		this.total_fat = total_fat;
		this.sodium = sodium;
		this.protein = protein;
	}
	
	/**
	 * @return the item name
	 */
	public String getItem(){
		return item;
	}
	
	/**
	 * @return the calories
	 */
	public int getCalories(){
		return calories;
	}
	
	/**
	 * @return the carbs
	 */
	public int getCarbohydrates(){
		return carbohydrates;
	}
	
	/**
	 * @return the total fat
	 */
	public int getTotalFat(){
		return total_fat;
	}
	
	/**
	 * @return the sodium content
	 */
	public int getSodium(){
		return sodium;
	}
	
	/**
	 * @return the protein
	 */
	public int getProtein(){
		return protein;
	}
	
	public String toStringTop(){
		return "Item: " + item + ", Calories: " + calories + ", Carbohydrates: " + carbohydrates;
	}

	public String toStringBottom()
	{
		return "Total Fat: " + total_fat + ", Sodium: " + sodium + ", Protein: " + protein;
	}
	
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((item == null) ? 0 : item.hashCode());
		result = prime * result + calories;
		result = prime * result + total_fat;
		result = prime * result + carbohydrates;
		result = prime * result + sodium;
		result = prime * result + protein;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		NutritionItem other = (NutritionItem) obj;
		if (item == null) {
			if (other.item != null)
				return false;
		} else if (!item.equals(other.item))
			return false;
		if (calories != other.calories)
			return false;
		if (total_fat != other.total_fat)
			return false;
		if (carbohydrates != other.carbohydrates)
			return false;
		if (sodium != other.sodium)
			return false;
		if (cholesterol != other.cholesterol)
			return false;
		if (protein != other.protein)
			return false;
		return true;
	}
}
